<template>
	<view>
		<view class="head">如果没有物流信息，则可不选择</view>
		<view class="logistics" @click="gokuai">
			<view class="logisticsLeft">物流公司</view>
			<view class="logisticsCenter">{{ kuaidi }}</view>
			<view class="logisticsLeftRight">
				<image src="../../static/images/arrow_right.png" mode=""></image>
			</view>
		</view>
		<view class="logistics">
			<view class="logisticsLeft">物流单号</view>
			<view class="logisticsCenter">
				<input type="text" value="" placeholder="请输入物流单号" v-model="dingnumber" :value="dingnumber" />
			</view>
			<view class="logisticsLeftRight">
				<image src="../../static/images/202010130319.png" mode="" style="width: 44rpx; height: 44rpx;"></image>
			</view>
		</view>
		<!-- 	<view class="heads">
			<view class="box-l">
				<view class="box-t">
			短信通知：
				</view>
				<view class="box-b">
				顺丰快递
				</view>
				</view>
			<view class="box-r">
				<view><switch checked @change="switch1Change" /></view>
			</view>
		</view> -->
		<button type="primary" @click="fahuo">确认发货</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				kuaidi: '',
				arry: {},
				add: '',
				operate_type: 4,
				customer_id: '',
				operate_id: 0,
				dingnumber: '',
				adb: {},
				order_id: '',
				customer_id: ''
			};
		},
		onLoad(e) {

			this.kuaidi = uni.getStorageSync('kuaidi')
			this.order_id = uni.getStorageSync('order_id')
			this.customer_id = uni.getStorageSync('khid')
		},
		onShow() {
			this.adb = uni.getStorageSync('fahuo')

		},
		methods: {
			switch1Change: function(e) {
				console.log('switch1 发生 change 事件，携带值为', e.target.value);
			},
			gokuai() {
				uni.navigateTo({
					url: '../shop/order/logistics'
				});
			},
			fahuo() {
				// console.log(this.adb);
				let c = {}

				c.order_id = this.order_id
				let d = []
				this.adb.forEach(item => {
					d.push(item.product_list)
				})
				let y = []


				d.forEach(item => {
					y.push({
						operate_num: item[0].number,
						product_id: item[0].product_id,
						remark: ''
					})
				})

				c.product_list = y
				c.operate_type = 4
				console.log(c);
				c.operate_id = 0;
				c.delivery_no = this.dingnumber;
				c.delivery_name = this.kuaidi;
				c.customer_id = this.customer_id

			
				this.$ajax('api/v1.stock/add', {
						0: JSON.stringify(c)
					})
					.then(res => {
						uni.showToast({
							title:'发货成功',
							icon:'none'
						})
						setTimeout(()=>{
						uni.switchTab({
							url:'../shop/indent'
						})
						},1000)
					
						
					})
					.catch(res => {
						console.log(Error);
					});
			}
		}
	};
</script>

<style lang="less">
	page {
		background-color: #f7f4f8;
	}

	.head {
		height: 88rpx;
		line-height: 88rpx;
		padding-left: 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(102, 102, 102, 1);
	}

	.logistics {
		height: 110rpx;
		line-height: 110rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
		background-color: #ffffff;
		display: flex;
		padding: 0 30rpx;
		justify-content: space-between;
		margin-bottom: 20rpx;

		.logisticsLeftRight {
			image {
				width: 18rpx;
				height: 33rpx;
				vertical-align: middle;
			}
		}

		.logisticsCenter {
			position: relative;
			left: -40rpx;

			input {
				margin-top: 30rpx;
				position: relative;
				left: 110rpx;
			}
		}
	}

	switch {
		transform: scale(0.8);
	}

	.heads {
		height: 157rpx;
		background-color: #ffffff;
		margin-top: 29rpx;
		padding: 30rpx 40rpx;
		display: flex;
		justify-content: space-between;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
		box-sizing: border-box;

		.box-b {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #666666;
			margin-top: 19rpx;
		}
	}

	button {
		position: fixed;
		width: 100%;
		bottom: 0;
	}
</style>
